<?php

namespace frontend\modules\user\controllers;

use frontend\components\Controller;

/**
 * 橙子兑换商城首页
 */
class CreditController extends Controller {

    public $modelClass = 'frontend\modules\user\models\CreditSearch';

    /**
     * {@inheritdoc}
     */
    public function actions() {
        return [
            'view' => [
                'class' => 'yii\rest\ViewAction',
                'modelClass' => $this->modelClass,
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function actionIndex() {
        /* @var $modelClass \frontend\modules\user\models\CreditSearch */
        $modelClass = new $this->modelClass;
        $modelClass->setToken($this->token);
        return $modelClass->search(\Yii::$app->request->getQueryParams());
    }

    public function actionCurrent() {
        /* @var $modelClass \frontend\modules\user\models\CreditSearch */
        $modelClass = new $this->modelClass;
        $modelClass->setToken($this->token);
        return $modelClass->current();
    }

}
